<template>
  <div class="container">
    <div v-for="block in directory" class="block-item">
      <div class="block-title">{{block.blockName}}</div>
      <div class="list-wrap">
        <div v-for="item in block.list" class="list-item" @click="toDetail(item)">
          <div class="pic">
            <img :src="item.img" v-if="item.img" />
            <div v-else class="text-pic">{{item.textPic}}</div>
          </div>
          <span class="title">{{item.title}}</span>
        </div>
        <div class="placeholder"></div>
        <div class="placeholder"></div>
        <div class="placeholder"></div>
        <div class="placeholder"></div>
      </div>
    </div>
  </div>
</template>

<script>
import directory from '../constant/directory.js';

export default {
  data() {
    
    return {
      directory
    };
  },
  methods: {
    toDetail({path}) {
      this.$router.push({path});
    }
  }
};
</script>

<style lang="less">
  * {
    -webkit-touch-callout:none;
    -webkit-user-select:none;
    -khtml-user-select:none;
    -moz-user-select:none;
    -ms-user-select:none;
    user-select:none;
  }
  @minColor: #3eaf7c;
  .line-clamp{
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .container {
    padding-bottom: 50px;
    .block-item {
      .block-title {
        font-size: 24px;
        font-weight: bold;
        position: relative;
        padding-left: 15px;
        margin: 30px 0 15px 0;
        &:before {
          content: '';
          display: block;
          width: 5px;
          height: 70%;
          background: @minColor;
          position: absolute;
          top: 15%;
          left: 0;
        }
      }
    }
    .list-wrap {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      margin-top: -10px;
      @media (max-width: 768px){
        .list-item{
              width: 100%!important;
          }
          .list-item:hover {
            box-shadow: none!important;
          }
      }
      .list-item {
        width: 24%;
        height: 200px;
        box-sizing: border-box;
        padding: 10px;
        border: 1px solid #eee;
        margin-top: 10px;
        transition: .3s;
        background: #fff;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        cursor: pointer;
        &:hover {
          box-shadow: 0 0px 30px 2px rgba(0, 0, 0, 0.2);
        }
        .pic {
          height: 150px;
          display: flex;
          justify-content: center;
          align-items: center;
          background: #5d7092;

          .text-pic {
            .line-clamp();
            width: 70%;
            text-align: center;
            color: #fff;
            font-size: 24px;
            font-weight: bold;
          }
        }
        .title {
          .line-clamp();
          font-size: 16px;
          font-weight: bold;
          // height: 44px;
          text-align: center;
        }
        .desc {
          .line-clamp();
          font-size: 12px;
          height: 34px;
        }
      }
      .placeholder {
        width: 24%;
        height: 0;
        visibility: hidden;
      }
    }
  }
</style>